<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>项目列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .mbox{
        padding:8px;
        background: #fff;
    }
    .item img{
        height: 40px;
    }
    .btn{
        height: 30px;
    }
    .btn button{
        float: right;
    }
    .information{
        background:#bfe8ff;
        height: 30px;
        line-height: 30px;
    }
    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
    #cont .layui-form-item {
        margin-bottom: 5px;
    }
    #cont .layui-input-inline{
        width: 300px !important;
    }
    .layui-table-tool{
        display: none;
    }
    .layui-table-view i{
        width: 18px;
        height: 18px;
        margin-top: 5px;
    }
</style>
<body>
<div class="mbox">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span style="font-size: 22px;display: inline-block;vertical-align: middle;">项目列表</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="btn">
        <%--<button type="button" class="layui-btn layui-btn-sm" style="margin-left: 20px;"><i class="layui-icon layui-icon-upload-drag"></i>导出Excel</button>--%>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
</body>
</html>
<script type="text/html" id="barDemo">
    {{#  if(d.sDirectorLeaderStatus == 2||d.sDirectorLeaderStatus ==3 ||d.sDirectorLeaderStatus ==null){ }}
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="look">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="declare">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
    {{#  }else{ }}
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="look">查看</a>
    {{#  } }}

</script>
<script>
    var userName = '', userId = '';
    layui.use(['table', 'form', 'laydate','upload'], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload;
        form.render()
        var tableInt
        function list(userId){
            tableInt=table.render({
                elem: '#test'
                , url: '/rpmTopic/selectProjectList?userId='+ userId
                // , url: '/Dictonary/selectDictionaryByNo?dictNo=' + dictNo

                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板

                ,parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code":0, //解析接口状态
                        "data": res.object, //解析数据列表，
                        "count": res.totleNum, //解析数据长度
                    };
                }
                , defaultToolbar: ['']
                , title: '用户数据表'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field:'planName', title: '计划名称'}
                    , {field: 'topicName', title: '项目名称'}
                    , {field: 'topicType', title: '项目类别'}
                    , {field: 'research', title: '研究领域'}
                    , {field: 'sDirectorLeaderStatus', title: '学校科研室主任审批状态',templet: function(d){
                            if(d.sDirectorLeaderStatus=='0'){
                                return '未审核'
                            }else if(d.sDirectorLeaderStatus=='1'){
                                return '通过'
                            }else if(d.sDirectorLeaderStatus=='2'){
                                return '退回'
                            }else if(d.sDirectorLeaderStatus=='8'){
                                return '不通过'
                            }else {
                                return''
                            }
                        }}
                    , {field: 'teacheerStatus', title: '学院老师审批状态',templet: function(d){
                            if(d.teacheerStatus=='0'){
                                return '未审核'
                            }else if(d.teacheerStatus=='1'){
                                return '通过'
                            }else if(d.teacheerStatus=='2'){
                                return '退回'
                            }else if(d.teacheerStatus=='8'){
                                return '不通过'
                            }else {
                                return''
                            }
                        }}
                    , {field: 'directorLeaderStatus', title: '学院教研主任审批状态',templet: function(d){
                            if(d.directorLeaderStatus=='0'){
                                return '未审核'
                            }else if(d.directorLeaderStatus=='1'){
                                return '通过'
                            }else if(d.directorLeaderStatus=='2'){
                                return '退回'
                            }else if(d.directorLeaderStatus=='8'){
                                return '不通过'
                            }else {
                                return''
                            }
                        }}
                    , {field: 'type', title: '操作', width:160,toolbar: '#barDemo'}
                ]]
                , page: true
            });
        }

        var topicId;
        table.on('checkbox(test)', function(obj){
            topicId=obj.data.topicId
        });
        $.ajax({
            url: '/Meetequipment/getuser',
            type: 'get',
            dataType: 'json',
            success: function (res) {
                $('table').attr('id',res.object.userId)
                userId = res.object.userId
                list(userId)
            }
        })
        list($.cookie('userId'))

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            var topicId = data.topicId
            if(obj.event === 'del'){
                layer.confirm('真的删除当前数据吗？', function (index) {
                    $.ajax({
                        type: 'get',
                        url: '/rpmTopic/delete?topicId='+topicId,
                        dataType: 'json',
                        success: function (res) {
                            if (res.msg == '删除成功') {
                                layer.msg('删除成功！', {icon: 1});
                                location.reload();
                                layer.closeAll();
                            }
                        }
                    })
                });
            }else if(obj.event == 'declare'){
                var planId = data.planId
                $(this).attr('href','/rpmPlan/rpmDeclaration1?topicId='+topicId+ '&planId=' + planId)
            }else{
                var userId = data.userId
                var planId = data.planId
                $(this).attr('href', '/rpmPlan/lookporiex?userId=' + userId + '&planId=' + planId)
            }
        });

    });
</script>
